@function breakpoint-min($name, $breakpoints: $grid-breakpoints) {
  $min: map-get($breakpoints, $name);
  @return if($min != 0, $min, null);
}

@function breakpoint-infix($name, $breakpoints: $grid-breakpoints) {
  @return if(breakpoint-min($name, $breakpoints) == null, '', '-#{$name}');
}

@mixin make-container($gutter: $grid-gutter-width) {
  padding-right: $gutter / 2;
  padding-left: $gutter / 2;
}

@mixin make-row($gutter: $grid-gutter-width) {
  margin-right: -$gutter / 2;
  margin-left: -$gutter / 2;
}

@mixin make-grid-columns(
  $columns: $grid-columns,
  $gutter: $grid-gutter-width,
  $breakpoints: $grid-breakpoints
) {
  %grid-column {
    padding-right: $gutter / 2;
    padding-left: $gutter / 2;
  }

  @each $breakpoint in map-keys($breakpoints) {
    $infix: breakpoint-infix($breakpoint, $breakpoints);

    @for $i from 1 through $columns {
      .col#{$infix}-#{$i} {
        @extend %grid-column;
      }
    }
    .col#{$infix},
    .col#{$infix}-auto {
      @extend %grid-column;
    }
  }
}

.container {
  @include make-container();
}

.container-fluid {
  @include make-container();
}

.row {
  @include make-row();
}

@include make-grid-columns();
